From 873985d3e45f31f62cdc0fbb3068932e9365b601 Mon Sep 17 00:00:00 2001 From: "mafetter@seana.research.intel-research.net" Date: Tue, 8 Nov 2005 11:29:07 +0100 Subject: [PATCH] Added some minor defensive coding/error handling in xc_linux_build.c --- tools/libxc/xc_linux_build.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tools/libxc/xc_linux_build.c b/tools/libxc/xc_linux_build.c index cf4db7cb69..cfc14bfb19 100644 --- a/tools/libxc/xc_linux_build.c +++ b/tools/libxc/xc_linux_build.c @@ -549,11 +549,10 @@ static int setup_guest(int xc_handle, rc = setup_pg_tables_pae(xc_handle, dom, ctxt, dsi.v_start, v_end, page_array, vpt_start, vpt_end); - else { + else rc = setup_pg_tables(xc_handle, dom, ctxt, dsi.v_start, v_end, page_array, vpt_start, vpt_end); - } #endif #if defined(__x86_64__) rc = setup_pg_tables_64(xc_handle, dom, ctxt, @@ -671,8 +670,10 @@ static int setup_guest(int xc_handle, return 0; error_out: - free(mmu); - free(page_array); + if ( mmu != NULL ) + free(mmu); + if ( page_array != NULL ) + free(page_array); return -1; } #endif @@ -726,7 +727,7 @@ int xc_linux_build(int xc_handle, if ( mlock(&st_ctxt, sizeof(st_ctxt) ) ) { - PERROR("xc_linux_build: ctxt mlock failed"); + PERROR("%s: ctxt mlock failed", __func__); return 1; } @@ -767,7 +768,8 @@ int xc_linux_build(int xc_handle, close(initrd_fd); if ( initrd_gfd ) gzclose(initrd_gfd); - free(image); + if ( image != NULL ) + free(image); #ifdef __ia64__ /* based on new_thread in xen/arch/ia64/domain.c */ @@ -856,7 +858,8 @@ int xc_linux_build(int xc_handle, gzclose(initrd_gfd); else if ( initrd_fd >= 0 ) close(initrd_fd); - free(image); + if ( image != NULL ) + free(image); return -1; } -- 2.30.2